package com.cw.reduce.filter;

import java.util.Vector;

public class SumFilter implements IFilter {
	private int type;

	public SumFilter(int type) {
		this.type = type;
	}

	/**
	 * startFilter
	 * 
	 * @param condition
	 *            Vector
	 * @param target
	 *            Vector
	 * @return Vector
	 * @todo Implement this cp.gui.reduce.filter.IFilter method
	 */
	public Vector startFilter(Vector condition, Vector<Integer> target) {
		Vector result = new Vector();
		switch (type) {
		case 0:
			for (int i = 0; i < target.size(); i++) {
				int value = target.elementAt(i);
				int sum = value % 10 + value / 10 % 10 + value / 100;

				if (!condition.contains(sum)) {
					result.add(value);
				}

			}
			break;
		case 1:
			for (int i = 0; i < target.size(); i++) {
				int value = target.elementAt(i);
				int sum = value % 10 + value / 10 % 10 + value / 100;
				if (condition.contains(sum)) {
					result.add(value);
				}
			}
			break;
		}

		return result;
	}
}
